package com.chinadci.smartcommunitysystembackstage.service;

import com.chinadci.smartcommunitysystembackstage.entity.ScsVisitor;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsAdmintypeMapper;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsVisitorMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@Service
public class ScsVisitorService{
    @Autowired
    private ScsVisitorMapper mapper;

    private Logger log= LoggerFactory.getLogger(this.getClass());

    //显示所有访客记录
    public List<ScsVisitor> Find(String name){
        log.info("=====显示访客记录");
        List<ScsVisitor> list=null;
        if (name!=null & name!=""){
            list=mapper.Find("%"+name+"%");
        }else{
            list=mapper.Find("%%");
        }
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setGx(list.get(i).getType().get(0).getVtName());
            list.get(i).setName(list.get(i).getUser().get(0).getUName());
        }
        return list;
    }

    //登记访客
    public int Insert(ScsVisitor scs){
        log.info("=====访客登记");
        return mapper.insert(scs);
    }
}
